package com.yuhj.ontheway.activity;

import com.yuhj.ontheway.R;
import com.yuhj.ontheway.fragment.JingXuanFragment;

import android.os.Bundle;
import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.Menu;
import android.view.Window;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.TextView;

/**
 * @name MainActivity
 * @Descripation 这是在路上主界面的设计类<br>
 *		1、精选<br>
 *		2、专题<br>
 *      3、活动<br>
 *      4、记录<br>
 * @author 禹慧军
 * @date 2014-10-22
 * @version 1.0
 */
public class MainActivity extends FragmentActivity implements OnCheckedChangeListener{
	private RadioButton jingXuanButton,zhuanTiButton,huoDongButton,jiLuButton;
	private ImageView imageView;
	private TextView title;
	private JingXuanFragment jingXuanFragment;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_main);
		initViews();
		FragmentManager manager =getSupportFragmentManager();
		FragmentTransaction transaction =manager.beginTransaction();
		transaction.add(R.id.main_framelayout, jingXuanFragment);
		title.setText("精选");
		transaction.commit();
	}
	private void initViews() {
		jingXuanButton=(RadioButton) findViewById(R.id.main_tab_item_jingxuan);
		zhuanTiButton=(RadioButton) findViewById(R.id.main_tab_item_zhuanti);
		huoDongButton=(RadioButton) findViewById(R.id.main_tab_item_hongdong);
		jiLuButton=(RadioButton) findViewById(R.id.main_tab_item_article);
		jingXuanButton.setOnCheckedChangeListener(this);
		zhuanTiButton.setOnCheckedChangeListener(this);
		huoDongButton.setOnCheckedChangeListener(this);
		jiLuButton.setOnCheckedChangeListener(this);
		jingXuanFragment =new JingXuanFragment();
		title=(TextView)findViewById(R.id.main_title);
	}
	@Override
	public void onCheckedChanged(CompoundButton view, boolean arg1) {
		FragmentManager manager =getSupportFragmentManager();
		FragmentTransaction transaction =manager.beginTransaction();
		if (view==jingXuanButton) {
			transaction.replace(R.id.main_framelayout,jingXuanFragment);
			title.setText("精选");
		}
		
		transaction.commit();
		
	}


}
